package cn.zzuli.springcloud.controller;

import cn.zzuli.commons.entity.CommonResult;
import cn.zzuli.commons.entity.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.UUID;

/**
 * @Date: 2020/12/26 13:15
 * @Author: 绯色下午茶
 * @Description:
 */
@RestController
@RequestMapping("/provider")
public class PaymentController {
    @Value("${server.port}")
    private String port;

    public static HashMap<Long, Payment> hashMap = new HashMap<>();

    static {
        hashMap.put(1l, new Payment(1l, UUID.randomUUID().toString()));
        hashMap.put(2l, new Payment(2l, UUID.randomUUID().toString()));
        hashMap.put(3l, new Payment(3l, UUID.randomUUID().toString()));
        hashMap.put(4l, new Payment(4l, UUID.randomUUID().toString()));
        hashMap.put(5l, new Payment(5l, UUID.randomUUID().toString()));
        hashMap.put(6l, new Payment(6l, UUID.randomUUID().toString()));
        hashMap.put(7l, new Payment(7l, UUID.randomUUID().toString()));
    }

    @GetMapping("/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id") long id) {
        Payment payment = hashMap.get(id);
        CommonResult<Payment> result = new CommonResult<>(200,
                "from mysql, serverport:  " + port,
                payment);

        return result;
    }



}
